<?php

namespace app\controller;

//二级市场控制器
use app\service\UserMarketService;
use support\Response;

class UserMarketController extends Base
{


   //二级市场-寄售列表
    public function list(): Response
    {
        //类型
        $type = $this->request->get('type',SECOND_MARKET_TYPE['所有']);

        if (!in_array($type,SECOND_MARKET_TYPE)){
            return $this->fail('类型错误');
        }
        //页码
        $page = $this->request->get('page',1);
        //每页数量
        $limit = $this->request->get('limit',10);
        $res = (new UserMarketService())->list($this->user_id,$type,$page,$limit);
        return json($res);
    }


   //二级市场-寄售
    public function sell()
    {



    }
    //二级市场-我的寄售
    public function my_sell_list(){

    }
    //二级市场-拍卖列表
    public function auction(){

    }
    //二级市场-拍卖详情
    public function auctionDetail(){

    }

    //二级市场-系统回收
    public function recycle(){

    }

    //二级市场-添加寄售
    public function add_sale(): Response
    {
        //卡牌ID
        $user_card_id = $this->request->post('user_card_id');
        //寄售价格
        $price = $this->request->post('price');
        //寄售截止时间
        $end_time = $this->request->post('end_time');

        $res = (new UserMarketService())->add_sale($this->user_id,$user_card_id,$price,$end_time);

        return json($res);
    }
    //二级市场-查看寄售
    public function saleDetail(){

    }

    //二级市场-订单记录
    public function orderRecord(){

    }




}